package san;

public class main {
	static Animal[] del(Animal[] a, String n) {
		Animal[] c = new Animal[a.length];
		for (int i = 0; i < a.length; i++) {
			c[i] = new Animal();
			if (a[i].Varieties != n && a[i].x > 0) {
				c[i] = a[i];
			} else {
				c[i].x = -1;
			}
		}
		return c;

	}

	public static void main(String[] args) {
		Animal[] a = { new wolf("狼"), new sheep("羊灰狼"), new finsh("鱼") };
		System.out.println("活动范围是8*8的矩形");
		int i = 0;
		while (i++ < 60) {
			System.out.println("第" + i + "回合");

			if (a[0].x > 0 && a[1].x > 0 && a[0].x == a[1].x && a[0].y == a[1].y) {
				a[0].display();
				a[1].display();
				System.out.println("此时" + a[0].Varieties + "和" + a[1].Varieties + "相遇，" + a[1].Varieties + "被吃掉了");
				a = del(a, "羊");
			} else if (a[0].x > 0 && a[2].x > 0 && a[0].x == a[2].x && a[0].y == a[2].y) {
				a[0].display();
				a[2].display();
				System.out.println("此时" + a[0].Varieties + "和" + a[2].Varieties + "相遇，" + a[2].Varieties + "被吃掉了");
				a = del(a, "鱼");
			} else if (a[2].x > 0 && a[1].x > 0 && a[1].x == a[2].x && a[1].y == a[2].y) {
				a[1].display();
				a[2].display();
				System.out.println("此时" + a[1].Varieties + "和" + a[2].Varieties + "相遇，" + a[2].Varieties + "被吃掉了");
				a = del(a, "鱼");
			} else if (a[0].x > 0 && a[1].x > 0 && a[2].x > 0 && a[0].x == a[1].x && a[1].x == a[2].x
					&& a[0].y == a[1].y && a[1].y == a[2].y) {
				a[0].display();
				a[0].display();
				a[2].display();
				System.out.println("此时" + a[0].Varieties + "、" + a[1].Varieties + "和" + a[2].Varieties + "相遇，"
						+ a[2].Varieties + "和" + a[1].Varieties + "被吃掉了");
				a = del(a, "鱼");
				a = del(a, "羊");
			}

			for (int n = 0; n < a.length; n++) {
				if (a[n].x > 0 || a[n].x == 0) {
					a[n].move();
					a[n].display();
				}
			}

		}
	}
}